package com.ali.common;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;

public class MapUtil {
//Map

    /**
     * 获取Map中键值对的个数
     */
    public static int size(Map<String, Object> map) {
        return map.size();
    }

    /**
     * 判断Map是否为空
     */
    public static boolean isEmpty(Map<String, Object> map) {
        return map.isEmpty();
    }

    /**
     * 获取Map的key集合
     */
    public static Set<String> keySet(Map<String, Object> map) {
        return map.keySet();
    }

    /**
     * 获取Map的value集合
     */
    public static Collection<Object> values(Map<String, Object> map) {
        return map.values();
    }

    /**
     * 删除Map中的键值对
     */
    public static Map<String, Object> remove(Map<String, Object> map, String key) {
        map.remove(key);
        return map;
    }

    /**
     * 删除Map中所有的键值对
     */
    public static Map<String, Object> clear(Map<String, Object> map) {
        map.clear();
        return map;
    }

    /**
     * 使Map变为不能修改
     */
    public static Map<String, Object> unmodifiableMap(Map<String, Object> map) {
        return Collections.unmodifiableMap(map);
    }
}